package com.mobilesafe.ui;

import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;

import com.mobilesafe.R;
import com.mobilesafe.adapter.SelectContactAdapter;
import com.mobilesafe.base.BaseActivity;
import com.mobilesafe.domain.ContactInfo;
import com.mobilesafe.engine.ContactInfoService;

public class SelectContactActivity extends BaseActivity {
	private List<ContactInfo> infos;
	private ListView lv;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		// 取消标题栏
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.select_contact);
		ContactInfoService service = new ContactInfoService(this);
		infos = service.getContactInfos();

		lv = (ListView) this.findViewById(R.id.lv_select_contact);
		lv.setAdapter(new SelectContactAdapter(infos,SelectContactActivity.this));
		lv.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				String phone = infos.get(position).getPhone();
				Intent intent = new Intent();
				intent.putExtra("number", phone);
				setResult(0, intent);
				finish();
			}
		});

	}

	@Override
	protected void findViewById() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void initView() {
		// TODO Auto-generated method stub

	}

}
